package com.seanbot.armstrong.poolgame;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

public class Ball {
	private int x;
	private int y;
	private int dx = 1;
	private int dy = 1;
	private int speedX = 10;
	private int speedY = 10;

	private int radius;

	private Paint paint = null;

	public Ball(int x, int y) {
		super();

		this.x = x;
		this.y = y;
		this.radius = 20;

		paint = new Paint();
		paint.setColor(Color.BLACK);
	}

	public void setCenterTo(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public void checkBounds(int width, int height) {
		if ((x - radius <= 0) || (x + radius >= width))
			dx *= (-1);
		if ((y - radius <= 0) || (y + radius >= height))
			dy *= (-1);
	}

	public void move() {
		x = x + dx * speedX;
		y = y + dy * speedY;
	}

	public void draw(Canvas canvas) {
		canvas.drawCircle(x, y, radius, paint);
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}
}
